//
//  GNRInputCardView.m
//  GNRPickCard_Example
//
//  Created by LvYuan on 2017/10/31.
//  Copyright © 2017年 ly918@qq.com. All rights reserved.
//

#import "GNRInputCardView.h"
#import <GNRCoreKit/UIColor+GNRExtension.h>
@implementation GNRInputCardView

- (void)setInputConfig:(id<GNRTextInputProtocol>)inputConfig{
    _inputConfig = inputConfig;
    [self configTextField];
}

- (void)configTextField{
    _textField.placeholder = self.inputConfig.placeholder;
    _textField.keyboardType = self.inputConfig.keyboardType;
    _infoL.text = self.inputConfig.tipsInfo;
}

- (void)awakeFromNib{
    [super awakeFromNib];
    _textFieldSuperView.layer.cornerRadius = 4;
    _textFieldSuperView.layer.masksToBounds = YES;
    [self.textField addTarget:self action:@selector(textFieldValueChanged:) forControlEvents:UIControlEventEditingChanged];
}

- (void)textFieldValueChanged:(UITextField *)textField{
    NSLog(@"textFieldValueChanged %@",textField.text);
    textField.textColor = textField.text?[UIColor blackColor]:[UIColor colorWithHexString:@"#cccccc"];
    if (_textFieldValueChangedBlock) {
        _textFieldValueChangedBlock(textField);
    }
}

- (void)setTextFieldValueChangedBlock:(void (^)(UITextField *))textFieldValueChangedBlock{
    _textFieldValueChangedBlock = nil;
    _textFieldValueChangedBlock = [textFieldValueChangedBlock copy];
}

@end
